<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
<%@ page import = "java.util.ArrayList" %>
<%@ page import = "quiz.Quiz" %>
<jsp:include page="templates/header.jsp" flush="true">
	<jsp:param value = "Take a Quiz | Quizzard" name = "title" />
</jsp:include>
<jsp:include page="templates/title_bar.jsp" flush = "true">
	<jsp:param value = "Take a Quiz" name = "title" />
</jsp:include>
<%
	ArrayList<Quiz> recent = (ArrayList<Quiz>)request.getAttribute("recentQuizzes");
	ArrayList<Quiz> popular = (ArrayList<Quiz>)request.getAttribute("popularQuizzes"); 
	ArrayList<String> tags = (ArrayList<String>)request.getAttribute("popularTags");
	
%>
<div id = "content">
<div class = "center">
<div class = "section_title bottom_border" style = "margin-left: 10px; margin-right: 10px;">Tags</div>
<div class = "split_left" style = "border: 0;">
<%
	for (int i = 0; i < tags.size() && i < 6; i++) {
%>
<div><a href = "ViewTag?tag=<%= tags.get(i) %>"><%= tags.get(i) %></a></div>
<%
	}
%>
</div>
<div class = "split_right" style = "border: 0;">
<%
	for (int i = 6; i < tags.size(); i++ ) { 
%>
<div><a href = "ViewTag?tag=<%= tags.get(i) %>"><%= tags.get(i) %></a></div>		
<%
}
%>
</div>
<div class = "clear padding"></div>
<div class = "split_left">
<div class = "section_title bottom_border">Popular</div>
<%
	if (popular == null) out.println("No popular quizzes");
	else {
		for(Quiz q: popular) {
			out.println("<div id = \"quiz\"><a href = \"ShowSelectedQuiz?id="+q.getID()+"\">"+q.getName()+"</a></div>");
		}
	}
%>
</div>
<div class = "split_right">
<div class = "section_title bottom_border">Recent</div>
<%
	if (recent == null) out.println("No recent quizzes");
	else {
		for(Quiz q: recent) {
			out.println("<div id = \"quiz\"><a href = \"ShowSelectedQuiz?id="+q.getID()+"\">"+q.getName()+"</a></div>");
		}
	}
%>
</div>
<br style = "clear: both;" />
</div>
</div>
<jsp:include page="templates/footer.jsp" flush="true" />